package xyz.migle.sc.demo.mapper;

import org.apache.ibatis.annotations.*;

//springboot会自动加载spring.datasource.*相关配置，数据源就会自动注入到sqlSessionFactory中，sqlSessionFactory会自动注入到Mapper中

//@Mapper 在程序入口处通过@MapperScan设置
@Mapper
public interface ChannelMapper {

//    @Select("SELECT * FROM channel WHERE channel_id = #{channelId}")
//    @Results({
//            @Result(property = "channelId",  column = "channel_id"),
//            @Result(property = "channelName", column = "channel_name")
//    })
//    Channel findById(@Param("channel_id") String channelId);
//
//    @Select("SELECT * FROM channel WHERE channel_name = #{channelName}")
//    @Results({
//            @Result(property = "channelId",  column = "channel_id"),
//            @Result(property = "channelName", column = "channel_name")
//    })
//    Channel findByName(@Param("channel_name") String channelName);

    @Insert("INSERT INTO channel(channel_id, channel_name) VALUES(#{channel_id}, #{channel_name})")
    int insert( @Param("channel_id") String channelId,  @Param("channel_name") String channelName);

}
